<?php
if($this->userlevel != "superadmin")
{
?>
<div class="edit-icoset" style="margin: 30px 120px 0 0;">
<?php if($this->userlevel == "bse") { ?>
<a href="javascript: void(0);" onclick="loadFrontPage('/event/addevent/userid/<?php echo $this->userid; ?>')"><img src="/images/icons/a-plus.gif" />Add Event</a>
<?php } ?>
</div>
<?php
}
?>

<?php
if(count($this->event_arr) > 0)
{
	echo "<script language='javascript' type='text/javascript'>";
	echo "$(document).ready(function() {
		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		$('#calendar').fullCalendar({
			selectable: true,
			editable: false,
			events: [";
			
			echo "{";
			
			foreach ($this->event_arr as $event_entry) {
				$event_date = $event_entry['date'];
				$start_time = $event_entry['start_time'];
				$event_date_format = explode("-", $event_date);
				
				$event_year = $event_date_format[0];
				$event_month = $event_date_format[1];
				$event_day = $event_date_format[2];
				
				$stime_arr = explode(":", $start_time);
				$stime_session = explode(" ", $start_time);
				$s_hr = $stime_arr[0];
				$s_min = $stime_arr[1];
				$stime_session = $stime_session[1];
				
				$description = substr(stripslashes(trim(strip_tags($event_entry['ACTIVITY_SUB'], ""))), 0, 8) . "...";
					
				echo "title: '". $description . "',";
					echo "start: new Date(y, m, " . $event_day . "), ";
					echo "end: new Date(y, m, " . $event_day . "), ";
					echo "url: 'javascript: showEventForm(" . $event_entry['event_id'] . ", " . $event_entry['customer_id'] . ")' ";							
				
				if(count($this->event_arr) > 1)
				{
					echo "},{";
				}
			}
			echo "}";		
		echo "]
			});
		});";
	echo "</script>"; 
} else {
	echo "<script language='javascript' type='text/javascript'>";
	echo "$(document).ready(function() {
			var date = new Date();
			var d = date.getDate();
			var m = date.getMonth();
			var y = date.getFullYear();
		$('#calendar').fullCalendar({
			selectable: true,
			editable: false,
			events: []";
		echo "
			});
		});";
	echo "</script>";
}
?>
<div id='calendar'></div>
<div id="formevents" style="display: none;" title="Event Viewer">
	<div id="formeventsdata"></div>
</div>

<div id="admineditevent" style="display: none;" title="Edit Customer Note">
	<div id="adminediteventdata"></div>
</div>